class Measure
  def initialize
    start
  end

  def to_s
    ret = []
    file, line = parse_caller(caller.first)
    ret << "Exection Time: #{exection_time} [sec]"
    ret << "FileName: #{file}, Line: #{line}"
    ret << "\n"
    ret.join("\n")
  end

  def start
    @start_time = Time.now
  end

  def reset
    start
  end

  def exection_time
    Time.now - @start_time
  end

  def parse_caller(at)
    if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
      file = $1
      line = $2.to_i
      [file, line]
    end
  end
end
